package com.neusoft.lohas.common.restTemplate.client;

import java.util.List;

import org.springframework.http.ResponseEntity;
public class ResourceHandleResult <T>{
	
	public final static int STATUS_SUCCESS = 0;
	public final static int STATUS_ERROR = 1;
	public final static int STATUS_NETWORK_ERROR = 404;
	private String message ;// = context.getResources().getString(R.string.STATUS_ERROR_MESSAGE);
	private int status = STATUS_SUCCESS;
	private T resourceEntity;
	
	public ResourceHandleResult(T resourceEntity){
		this.resourceEntity = resourceEntity;
	}
	public ResourceHandleResult(T resourceEntity,ResponseEntity<T> responseEntity){
		this.resourceEntity = resourceEntity;
		List<String> mStatus = responseEntity.getHeaders().get("Mstatus");
		if(mStatus!=null&&mStatus.size()>0){
			status = Integer.parseInt(mStatus.get(0));
			message =  responseEntity.getHeaders().get("Message").get(0);
		}
	}
	public ResourceHandleResult(T resourceEntity,int status,String message){
		this.resourceEntity = resourceEntity;
		this.status = status;
		this.message = message;
	}
	public final String getMessage() {
		return message;
	}
	public final void setMessage(String message) {
		this.message = message;
	}
	public final int getStatus() {
		return status;
	}
	public final void setStatus(int status) {
		this.status = status;
	}
	public final T getResourceEntity() {
		return resourceEntity;
	}
	public final void setResourceEntity(T resourceEntity) {
		this.resourceEntity = resourceEntity;
	}

}
